home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / TCP_IP / TNOS230S / FILES.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-09-14  |  17.1 KB  |  617 lines

  1. /* System-dependent definitions of various files, spool directories, etc */
  2. /* Mods by PA0GRI */
  3. #include "global.h"
  4. #ifndef MSDOS
  5. #include "ctype.h"
  6. #endif
  7. #include "commands.h"
  8. #include "netuser.h"
  9. #include "files.h"
  10. #include "mailbox.h"
  11.  
  12.  
  13. #if !defined(_lint)
  14. static char rcsid[] OPTIONAL = "$Id: files.c,v 1.31 1997/09/14 14:37:46 root Exp root $";
  15. #endif
  16.  
  17. const char *Alias      = "etc/alias";        /* the alias file */
  18. const char *ANSIArea      = "etc/menus/areas.bbs";    /* ANSI areas file */
  19. const char *ANSILogin      = "etc/menus/login.bbs";    /* ANSI login file */
  20. const char *AreaData      = "etc/help/areas.hlp";    /* Descriptions of message areas */
  21. const char *AreaSlist      = "etc/areas.sys";        /* List of message areas for sysops */
  22. const char *CommandHelp   = "etc/help/command.hlp";    /* Command Session Help file */
  23. const char *ConfNews      = "etc/help/confnews.txt";    /* conference bridge news file */
  24. const char *DomainFile      = "spool/domain.txt";        /* Domain cache */
  25. const char *EditorHelp      = "etc/help/editor.hlp";    /* Mini-Editor Help file */
  26. const char *ETCdir      = "etc";            /* the ETC direcory */
  27. const char *Fdbase      = "finger/dbase.dat";        /* Finger database */
  28. const char *FingerDir      = "finger";            /* Finger info directory */
  29. static const char *FileStructure = "structur.fil";    /* Runtime listing of filename used */
  30. const char *FTPHelp      = "etc/help/ftp.hlp";        /* FTP Help file */
  31. const char *Ftpmotd      = "etc/ftpmotd";        /* FTP message of the day */
  32. const char *Group      = "etc/groups";        /* the groups file */
  33. const char *Hostfile      = "etc/net.rc";        /* hosts and passwords */
  34. const char *LOGdir      = "spool/log";        /* log directory */
  35. const char *Maillog      = "spool/log/mail.log";    /* mail log */
  36. const char *Mailqdir      = "spool/mqueue";        /* Outgoing mail spool */
  37. const char *Mailqueue      = "spool/mqueue/*.wrk";    /* Outgoing mail work files */
  38. const char *Mailspool      = "spool/mail";        /* Incoming mail */
  39. const char *MANdir      = "man";            /* Manual pages base directory */
  40. const char *PBBSHelp      = "etc/help/pbbs.hlp";    /* PBBS Help file */
  41. const char *MOTDfile      = "etc/motd";            /* Mailbox MOTD file */
  42. const char *MOTDsysfile   = "etc/motd.sys";        /* Mailbox MOTD file for SYSOPs */
  43. const char *NEWUSERfile   = "etc/newuser";        /* New Pbbs User file */
  44. const char *Onexit      = "onexit.nos";        /* Commands to be executed on exiting */
  45. const char *PublicDir      = "public";            /* Public directory */
  46. const char *Quotes      = "etc/quotes";        /* List of quotes of the day */
  47. const char *Rewritefile   = "etc/rewrite";        /* Address rewrite file */
  48. const char *Routeqdir      = "spool/rqueue";        /* queue for router */
  49. const char *SMILEYFile      = "etc/help/smileys.txt";    /* conf smiley file */
  50. const char *Spool      = "spool";            /* Spool directory */
  51. const char *Startup      = "autoexec.nos";        /* Initialization file */
  52. const char *Userfile      = "etc/security";        /* Authorized users and passwords */
  53. const char *VersionFile   = "etc/help/version.hlp";    /* Command Session version file */
  54.  
  55. #ifdef ASKHOME
  56. const char *AskhomeFile   = "etc/askhome.dat";        /* Askhome prompt */
  57. #endif
  58.  
  59. #ifdef BBSEXPORT
  60. const char *EXPORTDir      = "spool/export";        /* Export directory */
  61. #endif
  62.  
  63. #ifdef BBSIMPORT
  64. const char *IMPORTDir      = "spool/import";        /* Import directory */
  65. #endif
  66.  
  67. #ifdef BROWSER
  68. const char *Cookiejar      = "spool/cookie.jar";        /* cookies received by local browser */
  69. const char *IncomingURLs  = "spool/incoming";        /* directory for files received by local browser */
  70. const char *CheckedURLs      = "spool/checked.url";    /* files with checked URL data */
  71. #endif
  72.  
  73. #ifdef CATALOG
  74. const char *CATALOGfile   = "etc/catalog.cat";        /* String Catalog file */
  75. #endif
  76.  
  77. #ifdef CONVERS
  78. const char *ConfHlp      = "etc/help/confmode.hlp";
  79. const char *ConfInfo      = "spool/confinfo";        /* Conferenge bridge user info */
  80. const char *NetControlHlp = "etc/help/netcntrl.hlp";
  81. #endif
  82.  
  83. #ifdef CRONTAB
  84. const char *CRONTABFile      = "spool/crontab";        /* Crontab file */
  85. #endif
  86.  
  87. #ifdef DELEGATE
  88. const char *DelegateFile  = "spool/mail/delegate";    /* delegation data file */
  89. #endif
  90.  
  91. #ifdef ENCAP
  92. const char *EncapRoutes      = "etc/encap-rt.dat";        /* Dynamic encap routes */
  93. #endif
  94.  
  95. #ifdef EXPIRY
  96. const char *Expirefile      = "etc/expire.dat";        /* Message expiration control file */
  97. #endif
  98.  
  99. #ifdef FIFOSERVER
  100. const char *FIFO_IN      = "spool/fifo_in";        /* FIFO input */
  101. const char *FIFO_OUT      = "spool/fifo_out";        /* FIFO output */
  102. #endif
  103.  
  104. #ifdef GPS
  105. const char *GPSfile      = "spool/GPSfile";        /* All heard GPS position data */
  106. #endif
  107.  
  108. #ifdef HOLDMODS
  109. const char *UserHoldFile  = "etc/userhold.dat";        /* file w/user name to hold mail from */
  110. const char *WordHoldFile  = "etc/wordhold.dat";        /* file w/words to hold mail if found in */
  111. #endif
  112.  
  113. #ifdef HTTP
  114. const char *Cookiefile      = "spool/cookie.cnt";        /* last cookie number assigned */
  115. const char *Cookiedata      = "spool/cookies.dat";    /* cookies assigned */
  116. const char *HTTPdir      = "http";            /* http root directory */
  117. const char *HTTPheadfile  = "wwwpre.cat";        /* http directory 'head' file */
  118. #ifdef UNIX
  119. const char *HTTPinclude      = ".message";            /* http directory 'include' file */
  120. #else
  121. const char *HTTPinclude      = "message.dat";        /* http directory 'include' file */
  122. #endif
  123. const char *HTTPtailfile  = "wwwpost.cat";        /* http directory 'tail' file */
  124. #endif
  125.  
  126. #if defined(MAILBOX) || defined(DELEGATE) || defined(REQSVR) || defined(MAILFILTER)
  127. const char *Helpdir      = "etc/help";            /* Mailbox help file directory */
  128. #endif
  129.  
  130. #ifdef MAILBOX
  131. const char *Historyfile   = "spool/history";        /* Message ID history file */
  132. const char *Signature      = "spool/signatur";        /* Mail signature file directory */
  133. #endif
  134.  
  135. #ifdef MAILCMDS
  136. const char *Arealist      = "etc/areas";        /* List of message areas */
  137. #endif
  138.  
  139. #ifdef MAILFILTER
  140. const char *FilterFile      = "etc/mbfilter.dat";        /* Mail filter data file */
  141. #endif
  142.  
  143. #ifdef MBFWD
  144. const char *Forwardfile   = "etc/forward.bbs";        /* Mail forwarding file */
  145. #endif
  146.  
  147. #ifdef NETROM
  148. const char *Netromfile      = "spool/netrom.sav";        /* Netrom node save file */
  149. #endif
  150.  
  151. #ifdef NODECALL
  152. const char *NODEHelp      = "etc/help/node.hlp";    /* NODE Help file */
  153. const char *NODEInfo      = "etc/help/nodeinfo.hlp";    /* NODE Info file */
  154. #endif
  155.  
  156. #if (defined(NNTP) || defined(NNTPS))
  157. const char *NNTPdir      = "spool/nnews";        /* News messages and NNTP data */
  158. const char *NNTPaccess      = "spool/nnews/access";
  159. #endif
  160.  
  161. #ifdef NNTPS
  162. const char *NNTPactive      = "spool/nnews/active";    /* */
  163. const char *NNTPforward      = "spool/nnews/forward";    /* */
  164. const char *NNTPhistory      = "spool/nnews/history";    /* */
  165. const char *NEWS2Mail      = "etc/news2mail";        /* */
  166. const char *NNTPhelp      = "spool/nnews/help";        /* */
  167. const char *NNTPinfo      = "spool/nnews/info";        /* */
  168. const char *NNTPpointer      = "spool/nnews/pointer";    /* */
  169. const char *NNTPpoll      = "spool/nnews/poll";        /* */
  170. #endif
  171.  
  172. #if (defined(POP) || defined(POP2CLIENT) || defined(POP2SERVER) || defined(POP3CLIENT) || defined(POP3SERVER))
  173. const char *Popusers      = "etc/popusers";        /* POP user and password file */
  174. #endif
  175.  
  176. #ifdef REJECT
  177. const char *REJECTFile      = "etc/reject.dat";        /* Message rejection file */
  178. #endif
  179.  
  180. #ifdef ROUTESERVER
  181. const char *RouteServer      = "etc/routesvr.dat";        /* Enabled remote encap routes */
  182. #endif
  183.  
  184. #ifdef STATS
  185. const char *STATSDir      = "spool/stats";        /* Statistics directory */
  186. #endif
  187.  
  188. #ifdef TUTOR
  189. const char *Info      = "spool/info";        /* Information Center directory */
  190. const char *News      = "spool/news";        /* News Center directory */
  191. const char *Tutor      = "spool/tutor";        /* Tutorial Server directory */
  192. const char *UCmdsHelp      = "etc/help/usercmds.hlp";    /* BBS CMD help file */
  193. const char *UserCmds      = "spool/cmds";        /* BBS CMD directory */
  194. #endif
  195.  
  196. #ifdef USERLOG
  197. const char *UDefaults      = "spool/users.dat";        /* User preference file */
  198. const char *UDefbak      = "spool/users.bak";
  199. #endif
  200.  
  201. #ifdef WPAGES
  202. const char *WhitePages      = "spool/wpages";        /* White Pages user log file */
  203. const char *WhitePagesBBS = "spool/wpagebbs";        /* White Pages bbs log file */
  204. const char *WPUpdateFile  = "spool/update.wp";        /* White Pages update temp file */
  205. #endif
  206.  
  207. #define    SEPARATOR    '/'
  208.  
  209. #ifdef UNIX
  210. #define ROOTDIR "."
  211. #else
  212. #define ROOTDIR "/"
  213. #endif
  214.  
  215. #ifdef MSDOS
  216. const char System[] = "MSDOS";
  217. const char Eol[]    = "\r\n";
  218. #endif
  219.  
  220. #ifdef TNOS_68K
  221. const char System[] = "OSK";
  222. const char Eol[]    = "\n";
  223. #endif
  224.  
  225. #ifdef    UNIX
  226. const char System[] = "UNIX";
  227. const char Eol[]    = "\n";
  228. const char *Command_sessmgr = "";
  229. const char *Trace_sessmgr = "";
  230. #endif
  231.  
  232.  
  233. const char *rootdir = ROOTDIR;
  234. static int Assigned;
  235. int Initroot;
  236. extern char *firstMsg;
  237.  
  238. static const char * setname (const char *name,char *file);
  239.  
  240.  
  241. /* Concatenate root, separator and arg strings into a malloc'ed output
  242.  * buffer, then remove repeated occurrences of the separator char
  243.  */
  244. void
  245. rootdircat(filenameptr)
  246. char const **filenameptr;
  247. {
  248. char *out;
  249. char const *filename = *filenameptr;
  250.  
  251.     if (rootdir && *rootdir)    {
  252.         if (*filename == SEPARATOR)
  253.             filename++;
  254.         out = mallocw (strlen (rootdir) + strlen (filename) + 2);
  255.         sprintf (out, "%s%c%s", rootdir, SEPARATOR, filename);
  256.         *filenameptr =  out;
  257.     }
  258. }
  259.  
  260.  
  261. struct filenaming {
  262.     const char *name;
  263.     int rootdircat;
  264.     char const **value;
  265. };
  266.  
  267. static struct filenaming Files[] = {
  268.     { "Alias",         1,    &Alias },
  269.     { "ANSIArea",         1,    &ANSIArea },
  270.     { "ANSILogin",        1,    &ANSILogin },
  271.     { "AreaData",        1,    &AreaData },
  272. #ifdef MAILCMDS
  273.     { "Arealist",        1,    &Arealist },
  274. #endif
  275.     { "AreaSlist",        1,    &AreaSlist },
  276.  
  277. #ifdef ASKHOME
  278.     { "AskhomeFile",    1,    &AskhomeFile },
  279. #endif
  280. #ifdef CATALOG
  281.     { "CATALOGfile",    1,    &CATALOGfile },
  282. #endif
  283. #ifdef BROWSER
  284.     { "CheckedURLs",    1,    &CheckedURLs },
  285. #endif
  286. #ifdef UNIX
  287.     { "Command_sessmgr",    0,    &Command_sessmgr },
  288. #endif
  289.     { "CommandHelp",    1,    &CommandHelp },
  290. #ifdef  CONVERS
  291.     { "ConfHlp",        1,    &ConfHlp },
  292.     { "ConfInfo",        1,    &ConfInfo },
  293. #endif
  294.     { "ConfNews",        1,    &ConfNews },
  295. #ifdef HTTP
  296.     { "Cookiedata",        1,    &Cookiedata },
  297.     { "Cookiefile",        1,    &Cookiefile },
  298. #endif
  299. #ifdef BROWSER
  300.     { "Cookiejar",        1,    &Cookiejar },
  301. #endif
  302. #ifdef CRONTAB
  303.     { "CRONTABFile",    1,    &CRONTABFile },
  304. #endif
  305. #ifdef DELEGATE
  306.     { "DelegateFile",    1,    &DelegateFile },
  307. #endif
  308.     { "DomainFile",        1,    &DomainFile },
  309.     { "EditorHelp",        1,    &EditorHelp },
  310. #ifdef ENCAP
  311.     { "EncapRoutes",    1,    &EncapRoutes },
  312. #endif
  313.     { "ETCdir",        1,    &ETCdir },
  314. #ifdef EXPIRY
  315.     { "Expirefile",        1,    &Expirefile },
  316. #endif
  317. #ifdef BBSEXPORT
  318.     { "EXPORTDir",        1,    &EXPORTDir },
  319. #endif
  320.     { "Fdbase",        1,    &Fdbase },
  321. #ifdef FIFOSERVER
  322.     { "FIFO_IN",        1,    &FIFO_IN },
  323.     { "FIFO_OUT",        1,    &FIFO_OUT },
  324. #endif
  325.     { "FileStructure",    1,    &FileStructure },
  326. #ifdef MAILFILTER
  327.     { "FilterFile",        1,    &FilterFile },
  328. #endif
  329.     { "FingerDir",        1,    &FingerDir },
  330. #ifdef MBFWD
  331.     { "Forwardfile",    1,    &Forwardfile },
  332. #endif
  333.     { "FTPHelp",        1,    &FTPHelp },
  334.     { "Ftpmotd",        1,    &Ftpmotd },
  335. #ifdef GPS
  336.     { "GPSfile",        1,    &GPSfile },
  337. #endif
  338.     { "Group",        1,    &Group },
  339. #ifdef MAILBOX
  340.     { "Helpdir",        1,    &Helpdir },
  341.     { "Historyfile",    1,    &Historyfile },
  342. #endif
  343.     { "Hostfile",        1,    &Hostfile },
  344. #ifdef HTTP
  345.     { "HTTPdir",        1,    &HTTPdir },
  346.     { "HTTPheadfile",    0,    &HTTPheadfile },
  347.     { "HTTPinclude",    0,    &HTTPinclude },
  348.     { "HTTPtailfile",    0,    &HTTPtailfile },
  349. #endif
  350. #ifdef BBSIMPORT
  351.     { "IMPORTDir",        1,    &IMPORTDir },
  352. #endif
  353. #ifdef BROWSER
  354.     { "IncomingURLs",    1,    &IncomingURLs },
  355. #endif
  356. #ifdef TUTOR
  357.     { "Info",        1,    &Info },
  358. #endif
  359.     { "LOGdir",        1,    &LOGdir },
  360.     { "Maillog",        1,    &Maillog },
  361.     { "Mailqdir",        1,    &Mailqdir },
  362.     { "Mailqueue",        1,    &Mailqueue },
  363.     { "Mailspool",        1,    &Mailspool },
  364.     { "MANdir",        1,    &MANdir },
  365.     { "MOTDfile",        1,    &MOTDfile },
  366.     { "MOTDsysfile",    1,    &MOTDsysfile },
  367. #ifdef  CONVERS
  368.     { "NetControlHlp",    1,    &NetControlHlp },
  369. #endif
  370. #ifdef NETROM
  371.     { "Netromfile",        1,    &Netromfile },
  372. #endif
  373. #ifdef TUTOR
  374.     { "News",        1,    &News },
  375. #endif
  376. #ifdef NNTPS
  377.     { "NEWS2Mail",        1,    &NEWS2Mail },
  378. #endif
  379.     { "NEWUSERfile",    1,    &NEWUSERfile },
  380. #ifdef NODECALL
  381.     { "NODEHelp",        1,    &NODEHelp },
  382.     { "NODEInfo",        1,    &NODEInfo },
  383. #endif
  384. #if (defined(NNTP) || defined(NNTPS))
  385.     { "NNTPaccess",        1,    &NNTPaccess },
  386. #endif
  387. #ifdef NNTPS
  388.     { "NNTPactive",        1,    &NNTPactive },
  389. #endif
  390. #if (defined(NNTP) || defined(NNTPS))
  391.     { "NNTPdir",        1,    &NNTPdir },
  392. #endif
  393. #ifdef NNTPS
  394.     { "NNTPforward",    1,    &NNTPforward },
  395.     { "NNTPhelp",        1,    &NNTPhelp },
  396.     { "NNTPhistory",    1,    &NNTPhistory },
  397.     { "NNTPinfo",        1,    &NNTPinfo },
  398.     { "NNTPpointer",    1,    &NNTPpointer },
  399.     { "NNTPpoll",        1,    &NNTPpoll },
  400. #endif
  401.     { "Onexit",        1,    &Onexit },
  402.     { "PBBSHelp",        1,    &PBBSHelp },
  403. #if (defined(POP) || defined(POP2CLIENT) || defined(POP2SERVER) || defined(POP3CLIENT) || defined(POP3SERVER))
  404.     { "Popusers",        1,    &Popusers },
  405. #endif
  406.     { "PublicDir",        1,    &PublicDir },
  407.     { "Quotes",        1,    &Quotes },
  408. #ifdef REJECT
  409.     { "REJECTFile",        1,    &REJECTFile },
  410. #endif
  411.     { "Rewritefile",    1,    &Rewritefile },
  412.     { "Routeqdir",        1,    &Routeqdir },
  413. #ifdef ROUTESERVER
  414.     { "RouteServer",    1,    &RouteServer },
  415. #endif
  416. #ifdef MAILBOX
  417.     { "Signature",        1,    &Signature },
  418. #endif
  419.     { "SMILEYFile",        1,    &SMILEYFile },
  420.     { "Spool",        1,    &Spool },
  421.     { "Startup",        1,    &Startup },
  422. #ifdef STATS
  423.     { "STATSDir",        1,    &STATSDir },
  424. #endif
  425. #ifdef UNIX
  426.     { "Trace_sessmgr",    0,    &Trace_sessmgr },
  427. #endif
  428. #ifdef TUTOR
  429.     { "Tutor",        1,    &Tutor },
  430.     { "UCmdsHelp",        1,    &UCmdsHelp },
  431. #endif
  432. #ifdef USERLOG
  433.     { "UDefaults",        1,    &UDefaults },
  434.     { "UDefbak",        1,    &UDefbak },
  435. #endif
  436. #ifdef TUTOR
  437.     { "UserCmds",        1,    &UserCmds },
  438. #endif
  439.     { "Userfile",        1,    &Userfile },
  440. #ifdef HOLDMODS
  441.     { "UserHoldFile",    1,    &UserHoldFile },
  442. #endif
  443.     { "VersionFile",    1,    &VersionFile },
  444. #ifdef WPAGES
  445.     { "WhitePages",        1,    &WhitePages },
  446.     { "WhitePagesBBS",    1,    &WhitePagesBBS },
  447. #endif
  448. #ifdef HOLDMODS
  449.     { "WordHoldFile",    1,    &WordHoldFile },
  450. #endif
  451. #ifdef WPAGES
  452.     { "WPUpdateFile",    1,    &WPUpdateFile },
  453. #endif
  454.     { NULLCHAR,        0,    (char const **)0 }
  455. };
  456.  
  457.  
  458.  
  459. /* Establish a root directory other than the default. Can only be called
  460.  * once, at startup time
  461.  */
  462. void
  463. initroot(root)
  464. char *root;
  465. {
  466. int k;
  467.     if(Assigned) {
  468.         firstMsg = strdup ("\007-f option used, -d ignored !\n");
  469.         return;
  470.     }
  471. #ifdef  MSDOS
  472.     undosify(root);
  473. #endif
  474.     if (root[strlen(root) - 1] == SEPARATOR)
  475.         root[strlen(root) - 1] = 0;
  476.     rootdir = strdup( root );
  477.  
  478.     /* we must re-do the original files listed, and delete the
  479.        one previously created
  480.      */
  481.     unlink (FileStructure);
  482.     list_filenames (2);
  483.     
  484.     /* loop to call rootdircat (&var) */
  485.     for (k = 0; Files[k].name != NULLCHAR; k++)
  486.         if (Files[k].rootdircat)
  487.             rootdircat(Files[k].value);
  488.     
  489.     Initroot = 1;
  490. }
  491.  
  492.  
  493. static const char * setname (const char *name, char *file)
  494. {
  495. int k;
  496.  
  497.     for (k = 0; Files[k].name != NULLCHAR; k++)    {
  498.         if (!stricmp (Files[k].name, name))
  499.             break;
  500.     }
  501.     if (Files[k].name == NULLCHAR)
  502.         return NULLCHAR;
  503.  
  504.     if (Initroot)
  505.         free (*(Files[k].value));
  506.     *(Files[k].value) = strdup (file);
  507.  
  508.     return (*(Files[k].value));
  509. }
  510.  
  511.  
  512. #define BUFLEN 128
  513.  
  514. void
  515. assign_filenames(config, verbose)
  516. const char *config;
  517. int verbose;
  518. {
  519. FILE *fp;
  520. char *name,*file,*cp;
  521. int line;
  522. char buf[BUFLEN+1];
  523. char buf2[BUFLEN+1];
  524.  
  525.     strncpy (buf, config, BUFLEN);
  526. #ifdef MSDOS
  527.     undosify (buf);
  528. #endif
  529.     if ((fp = fopen (buf, "r")) == NULL) {
  530.         if (verbose)    {
  531.             sprintf (buf2, "Cannot open '%s'\n", buf);
  532.             firstMsg = strdup (buf2);
  533.         }
  534.         return;
  535.     }
  536.  
  537.     line = 0;
  538.     while (fgets (buf, BUFLEN, fp) != NULL) {
  539.         line++;
  540.         if (*buf == '#')         /* comment */
  541.             continue;
  542.         rip (buf);   /* delete ending \n */
  543.         name = skipwhite (buf);
  544.         if (*name == '\0')      /* blank line */
  545.             continue;
  546.         /* Search for filename */
  547.         if ((file = strchr (name, '=')) == NULL) {
  548.             printf ("Need '=', line %d of %s.\n", line, config);
  549.             continue;
  550.         }
  551.         *file++ = '\0';
  552.         /* cut trailing spaces */
  553.         if ((cp = strchr (name,' ')) != NULL)
  554.             *cp = '\0';
  555.  
  556.         /* find start of filename */
  557.         file = skipwhite (file);
  558.  
  559.         if (*file == '\0')
  560.             continue;
  561.  
  562.         /* cut trailing spaces */
  563.         if ((cp = strchr (file, ' ')) != NULL)
  564.             *cp = '\0';
  565.  
  566.         /* Now parse the name, and assign if valid */
  567.         (void) setname (name, file);
  568.     }
  569.     (void) fclose (fp);
  570.     Assigned = 1;
  571. }
  572.  
  573.  
  574.  
  575. void
  576. list_filenames (int create)
  577. {
  578. int k;
  579. FILE *fp;
  580. const char *mode;
  581. char file[512];
  582. time_t nowtime;
  583.  
  584.     
  585.     strncpy (file, FileStructure, 512);
  586.     mode = WRITE_TEXT;
  587.     nowtime = time ((time_t *)0);
  588.     switch (create)    {
  589.         case 0:        /* use current and append */
  590.             mode = APPEND_TEXT;
  591.             break;
  592.         case 2:        /* use new location and create new */
  593.             sprintf (file, "%s/%s", rootdir, FileStructure);
  594.             break;
  595.         case 1:        /* use current and create new */
  596.         default:
  597.             break;
  598.     }
  599.         
  600.     fp = fopen (file, mode);
  601.     if (fp != NULLFILE)    {
  602.         if (create)    {
  603.             fprintf (fp, "#\n# Default values for configurable files, directories, and session managers\n"
  604.                 "#\n# The first section of this file lists the defaults for these\n#\n");
  605.             fprintf (fp, "# %s\n# Created: %s#\n\n", Version, ctime (&nowtime));
  606.  
  607.         } else
  608.             fprintf (fp, "\n#\n# Values in use for configurable files, directories, and session managers\n"
  609.             "#\n# This section of the file can be modified and used as a configuration file\n"
  610.             "# with the '-f' command line option, if desired.\n#\n\n");
  611.         for (k = 0; Files[k].name != NULLCHAR; k++)
  612.             fprintf (fp, "%-15.15s = %s\n", Files[k].name, *(Files[k].value));
  613.  
  614.         (void) fclose (fp);
  615.     }
  616. }
  617.